<template>
  <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
    <el-menu-item index="1">个人信息</el-menu-item>
    <el-menu-item v-if = "isApplicant" index="2">在线简历</el-menu-item>
    <el-menu-item v-if="isApplicant" index="3">附件简历</el-menu-item>
    <el-menu-item v-if="isApplicant" index="4">简历投递</el-menu-item>
  </el-menu>
</template>

<script setup>
import {onMounted, ref} from 'vue';
import router from "@/router";
const user = JSON.parse(localStorage.getItem('user'));
const activeIndex = ref('1');

const isApplicant = ref(false);
const handleSelect = (key) => {
  console.log(key);
  switch (key) {
    case '1':
      router.push('/personal-information');
      break;
    case '2':
      router.push('/job-seeker/resume');
      break;
    case '3':
      router.push('/job-seeker/attachment-resume');
      break;
    case '4':
      router.push('/chat');
      break;
  }
};
onMounted(() => {
  const user = getUser();
  if (user !== null) {
    const role = user.role;
    isApplicant.value = role === 2;
  }
});
</script>

<style scoped>
.el-menu-demo {
  width: 100%;
  background-color: #007bff;
  border-bottom: 1px solid #dcdcdc;
  margin-left: 0;
}
</style>
